package org.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.domain.po.ErpMaterialExtend;
import org.example.service.ErpMaterialExtendService;
import org.example.mapper.ErpMaterialExtendMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author 24059
* @description 针对表【erp_material_extend(产品价格扩展)】的数据库操作Service实现
* @createDate 2024-11-04 08:34:54
*/
@Service
public class ErpMaterialExtendServiceImpl extends ServiceImpl<ErpMaterialExtendMapper, ErpMaterialExtend>
    implements ErpMaterialExtendService{

    @Autowired
    private ErpMaterialExtendMapper erpMaterialExtendMapper;

    @Override
    public boolean addMaterialExtend(ErpMaterialExtend materialExtend) {
        int result = erpMaterialExtendMapper.insertMaterialExtend(materialExtend);
        return result > 0;
    }


    // 添加删除方法

    // 实现删除扩展信息的方法
    @Override
    @Transactional // 添加事务管理
    public boolean deleteByMaterialId(Long materialId) {
        return erpMaterialExtendMapper.deleteByMaterialId(materialId) > 0;
    }

    @Override
    @Transactional
    public boolean updateMaterialExtend(ErpMaterialExtend extend) {
        return updateById(extend); // 更新扩展信息
    }

    @Override
    public List<ErpMaterialExtend> selectByMaterialId(Long materialId) {
        return erpMaterialExtendMapper.selectByMaterialId(materialId);
    }
}




